package classes.managers {
	import classes.buttons.BaseButton;
	import classes.global.Global_Properties;
	import classes.scenes.A_Scene;
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author Kihoonee
	 */
	public class Rank_Manager extends A_Scene {
		
		private var closeBtn:BaseButton;
		private var rePlayBtn:BaseButton;
		
		public function Rank_Manager( _main:Main, _mc:MovieClip ) {
			super( _main, _mc );
			
			addEvent();
		}
		
		public function myData( _xml:XML ):void {
			mc.id_txt.text = Global_Properties.nick;
			mc.score_txt.text = Global_Properties.score;
			mc.rank_txt.text = _xml.rank;
		}
		
		public function rankData( _xml:XML ):void {
			var i:int;
			var length:int = _xml.row.length();
			for (i = 0; i < length; i++) {
				if ( _xml.row.nick[i] == null ) {
					
				}else {
					if ( i < 10 ) {
						mc["no" + (i + 1) + "_txt"].text = _xml.row.nick[i];
						mc["no" + (i + 1) + "_score"].text = _xml.row.score[i];
					}else {
						switch (i) {
							case 10: mc["no" + (i + 1) + "_txt"].text = _xml.row.nick[i]; mc["no" + (i + 1) + "_score"].text = _xml.row.score[i];
							break;
							case 20: mc["no" + (i + 1) + "_txt"].text = _xml.row.nick[i]; mc["no" + (i + 1) + "_score"].text = _xml.row.score[i];
							break;
							case 30: mc["no" + (i + 1) + "_txt"].text = _xml.row.nick[i]; mc["no" + (i + 1) + "_score"].text = _xml.row.score[i];
							break;
							case 40: mc["no" + (i + 1) + "_txt"].text = _xml.row.nick[i]; mc["no" + (i + 1) + "_score"].text = _xml.row.score[i];
							break;
							case 50: mc["no" + (i + 1) + "_txt"].text = _xml.row.nick[i]; mc["no" + (i + 1) + "_score"].text = _xml.row.score[i];
							break;
							case 60: mc["no" + (i + 1) + "_txt"].text = _xml.row.nick[i]; mc["no" + (i + 1) + "_score"].text = _xml.row.score[i];
							break;
							case 70: mc["no" + (i + 1) + "_txt"].text = _xml.row.nick[i]; mc["no" + (i + 1) + "_score"].text = _xml.row.score[i];
							break;
							case 80: mc["no" + (i + 1) + "_txt"].text = _xml.row.nick[i]; mc["no" + (i + 1) + "_score"].text = _xml.row.score[i];
							break;
							case 90: mc["no" + (i + 1) + "_txt"].text = _xml.row.nick[i]; mc["no" + (i + 1) + "_score"].text = _xml.row.score[i];
							break;
							case 100: mc["no" + (i + 1) + "_txt"].text = _xml.row.nick[i]; mc["no" + (i + 1) + "_score"].text = _xml.row.score[i];
							break;
							default:
						}
					}
				}
			}
		}
		
		private function addEvent():void {
			closeBtn = new BaseButton( mc.close_btn );
			closeBtn.addEventListener( MouseEvent.CLICK, BtnEvent );
			
			rePlayBtn = new BaseButton( mc.rePlay_btn );
			rePlayBtn.addEventListener( MouseEvent.CLICK, BtnEvent );
		}
		
		private function BtnEvent(e:MouseEvent):void {
			switch ( e.target.name ) {
				case "close_btn":
					main.end();
				break;
				case "rePlay_btn":
					main.viewChange( "game" );
					main.game1Init();
				break;
				default:
			}
		}
	}

}